﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "制作样信息";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool">
    <input id="txtBatch" type="text" class="condition-batch" placeholder="批次编码" />
    <input id="txtStartDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', maxDate: '#F{$dp.$D(\'txtEndDate\')}' })" type="text" class="condition-date" placeholder="开始时间" />
    <input id="txtEndDate" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'txtStartDate\')}' })" type="text" class="condition-date" placeholder="结束时间" />
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnExport", "fa fa-level-up", Resource.Export, ref perm, "Export", true)
</div>
<table id="List"></table>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">
    @Html.Raw(GridHelper.GridFormatterFunc<Wantn.FIS.Enum.CheckType>("gConvertCheckType"))

    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'BATCH_CODE',
            sortOrder: 'desc',
            idField: 'BATCH_CODE',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            onLoadSuccess: function(data) {
            },
            columns: [[
                { field: 'BATCH_CODE', title: '批次编码', width: 80, sortable: true },
                { field: 'MAKE_CODE', title: '制样编码',sortable: true },
                { field: 'MAKE_ID', title: '制样编号', width: 80, hidden: true },
                { field: 'MATERIEL_NAME', title: '物料', width: 60, sortable: true },
                { field: 'MINE_NAME', title: '矿点', width: 60, sortable: true },
                { field: 'SUPPLIER_NAME', title: '供应商',width:150, sortable: true },
                { field: 'TRANSPORT_NAME', title: '运输商',width:150 ,sortable: true },
                { field: 'EQUIPMENT_NAME', title: '制样机设备名', width: 80, sortable: true },
                { field: 'MAKE_WEIGHT', title: '制样重量', width: 60, sortable: true ,hidden:true},
                {
                    field: 'SAMPLE_TYPE', title: '样品类型', width: 60, sortable: true, formatter: function (val) {
                        switch (val) {
                            case 0:
                                return "入厂";
                                break;
                            case 1:
                                return "入炉";
                                break;
                            default:
                                return val;
                                break;
                        }
                    }
                },
                { field: 'BEGIN_TIME', title: '开始时间', width: 120, sortable: true },
                { field: 'END_TIME', title: '结束时间', width: 120, sortable: true },
                {
                    field: 'MAKE_MODE', title: '制样方式', width: 60, sortable: true, formatter: function (val) {
                        switch (val) {
                            case 0:
                                return "机器";
                                break;
                            case 1:
                                return "人工";
                                break;
                            default:
                                return val;
                                break;
                        }
                    }
                },
                { field: 'MAKE_USER_NAME', title: '操作员', width: 60, sortable: true },
                {
                    field: 'STATUS_STR', title: '制样状态', width: 60, sortable: true},
                { field: 'P_TIME', title: 'PDA提交时间', width: 120, sortable: true,hidden:true },
                { field: 'P_USER_NAME', title: 'PDA操作员', width: 60, sortable: true ,hidden:true},
            ]]
        });
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnQuery").click(function () {
            $("#List").datagrid("load", {
                batch: $("#txtBatch").val(),
                startDate: $("#txtStartDate").val(),
                endDate: $("#txtEndDate").val(),
            });

        });
        $("#btnExport").click(function () {
            var condition = "batch=" + $("#txtBatch").val() +
                        "&startDate=" + $("#txtStartDate").val() +
                        "&endDate=" + $("#txtEndDate").val();
            $.post("@Url.Action("CheckExportData")?" + condition, function (data) {
                if (data.type == 1) {
                    window.location = "@Url.Action("Export")?" + condition;
                }
                else {
                    $.messageBox5s(Lang.Tip, data.message);
                }
            }, "json");
        });
    });
</script>
